﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Linq.Expressions;
using System.Collections;
using System.Drawing.Design;
using System.Collections.Specialized;

#pragma warning disable 1591

namespace Dzzzr
{
	[System.Data.Linq.Mapping.DatabaseAttribute(Name = "Monitorng")]
	public partial class MonitoringDBDataContext : System.Data.Linq.DataContext
	{

		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

		#region Extensibility Method Definitions
		partial void OnCreated();
		partial void InsertEntity(Dzzzr.Entity instance);
		partial void UpdateEntity(Dzzzr.Entity instance);
		partial void DeleteEntity(Dzzzr.Entity instance);
		partial void InsertUserToRole(Dzzzr.UserToRole instance);
		partial void UpdateUserToRole(Dzzzr.UserToRole instance);
		partial void DeleteUserToRole(Dzzzr.UserToRole instance);
		partial void InsertEntityAttribute(Dzzzr.EntityAttribute instance);
		partial void UpdateEntityAttribute(Dzzzr.EntityAttribute instance);
		partial void DeleteEntityAttribute(Dzzzr.EntityAttribute instance);
		partial void InsertEntityAttributeType(Dzzzr.EntityAttributeType instance);
		partial void UpdateEntityAttributeType(Dzzzr.EntityAttributeType instance);
		partial void DeleteEntityAttributeType(Dzzzr.EntityAttributeType instance);
		partial void InsertEntityType(Dzzzr.EntityType instance);
		partial void UpdateEntityType(Dzzzr.EntityType instance);
		partial void DeleteEntityType(Dzzzr.EntityType instance);
		partial void InsertGame(Dzzzr.Game instance);
		partial void UpdateGame(Dzzzr.Game instance);
		partial void DeleteGame(Dzzzr.Game instance);
		partial void InsertGameEntity(Dzzzr.GameEntity instance);
		partial void UpdateGameEntity(Dzzzr.GameEntity instance);
		partial void DeleteGameEntity(Dzzzr.GameEntity instance);
		partial void InsertGameRole(Dzzzr.GameRole instance);
		partial void UpdateGameRole(Dzzzr.GameRole instance);
		partial void DeleteGameRole(Dzzzr.GameRole instance);
		partial void InsertGPSPoint(Dzzzr.GPSPoint instance);
		partial void UpdateGPSPoint(Dzzzr.GPSPoint instance);
		partial void DeleteGPSPoint(Dzzzr.GPSPoint instance);
		partial void InsertMarkerHash(Dzzzr.MarkerHash instance);
		partial void UpdateMarkerHash(Dzzzr.MarkerHash instance);
		partial void DeleteMarkerHash(Dzzzr.MarkerHash instance);
		partial void InsertTeam(Dzzzr.Team instance);
		partial void UpdateTeam(Dzzzr.Team instance);
		partial void DeleteTeam(Dzzzr.Team instance);
		partial void InsertUser(Dzzzr.User instance);
		partial void UpdateUser(Dzzzr.User instance);
		partial void DeleteUser(Dzzzr.User instance);
		partial void InsertUserRole(Dzzzr.UserRole instance);
		partial void UpdateUserRole(Dzzzr.UserRole instance);
		partial void DeleteUserRole(Dzzzr.UserRole instance);
		#endregion

		public MonitoringDBDataContext() :
			base(global::Dzzzr.Properties.Settings.Default.MonitorngConnectionString, mappingSource)
		{
			OnCreated();
		}

		public MonitoringDBDataContext(string connection) :
			base(connection, mappingSource)
		{
			OnCreated();
		}

		public MonitoringDBDataContext(System.Data.IDbConnection connection) :
			base(connection, mappingSource)
		{
			OnCreated();
		}

		public MonitoringDBDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
			base(connection, mappingSource)
		{
			OnCreated();
		}

		public MonitoringDBDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
			base(connection, mappingSource)
		{
			OnCreated();
		}

		public System.Data.Linq.Table<Dzzzr.Entity> Entities
		{
			get
			{
				return this.GetTable<Dzzzr.Entity>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.UserToRole> UserToRoles
		{
			get
			{
				return this.GetTable<Dzzzr.UserToRole>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.EntityAttribute> EntityAttributes
		{
			get
			{
				return this.GetTable<Dzzzr.EntityAttribute>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.EntityAttributeType> EntityAttributeTypes
		{
			get
			{
				return this.GetTable<Dzzzr.EntityAttributeType>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.EntityType> EntityTypes
		{
			get
			{
				return this.GetTable<Dzzzr.EntityType>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.Game> Games
		{
			get
			{
				return this.GetTable<Dzzzr.Game>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.GameEntity> GameEntities
		{
			get
			{
				return this.GetTable<Dzzzr.GameEntity>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.GameRole> GameRoles
		{
			get
			{
				return this.GetTable<Dzzzr.GameRole>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.GPSPoint> GPSPoints
		{
			get
			{
				return this.GetTable<Dzzzr.GPSPoint>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.MarkerHash> MarkerHashes
		{
			get
			{
				return this.GetTable<Dzzzr.MarkerHash>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.Team> Teams
		{
			get
			{
				return this.GetTable<Dzzzr.Team>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.User> Users
		{
			get
			{
				return this.GetTable<Dzzzr.User>();
			}
		}

		public System.Data.Linq.Table<Dzzzr.UserRole> UserRoles
		{
			get
			{
				return this.GetTable<Dzzzr.UserRole>();
			}
		}
	}

	[Table(Name = "dbo.Entity")]
	public partial class Entity : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private string _Name;

		private string _Description;

		private int _TeamID;

		private System.Data.Linq.Binary _Photo;

		private int _EntityTypeID;

		private EntitySet<EntityAttribute> _EntityAttributes;

		private EntitySet<GameEntity> _GameEntities;

		private EntitySet<GPSPoint> _GPSPoints;

		private EntityRef<EntityType> _EntityType;

		private EntityRef<Team> _Team;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnNameChanging(string value);
		partial void OnNameChanged();
		partial void OnDescriptionChanging(string value);
		partial void OnDescriptionChanged();
		partial void OnTeamIDChanging(int value);
		partial void OnTeamIDChanged();
		partial void OnPhotoChanging(System.Data.Linq.Binary value);
		partial void OnPhotoChanged();
		partial void OnEntityTypeIDChanging(int value);
		partial void OnEntityTypeIDChanged();
		#endregion

		public Entity()
		{
			this._EntityAttributes = new EntitySet<EntityAttribute>(new Action<EntityAttribute>(this.attach_EntityAttributes), new Action<EntityAttribute>(this.detach_EntityAttributes));
			this._GameEntities = new EntitySet<GameEntity>(new Action<GameEntity>(this.attach_GameEntities), new Action<GameEntity>(this.detach_GameEntities));
			this._GPSPoints = new EntitySet<GPSPoint>(new Action<GPSPoint>(this.attach_GPSPoints), new Action<GPSPoint>(this.detach_GPSPoints));
			this._EntityType = default(EntityRef<EntityType>);
			this._Team = default(EntityRef<Team>);
			OnCreated();
		}

		[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
		[Browsable(false)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_Name", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}

		[Column(Storage = "_Description", DbType = "NVarChar(250)")]
		public string Description
		{
			get
			{
				return this._Description;
			}
			set
			{
				if ((this._Description != value))
				{
					this.OnDescriptionChanging(value);
					this.SendPropertyChanging();
					this._Description = value;
					this.SendPropertyChanged("Description");
					this.OnDescriptionChanged();
				}
			}
		}

		[Column(Storage = "_TeamID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int TeamID
		{
			get
			{
				return this._TeamID;
			}
			set
			{
				if ((this._TeamID != value))
				{
					if (this._Team.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTeamIDChanging(value);
					this.SendPropertyChanging();
					this._TeamID = value;
					this.SendPropertyChanged("TeamID");
					this.OnTeamIDChanged();
				}
			}
		}

		[Column(Storage = "_Photo", DbType = "Image", UpdateCheck = UpdateCheck.Never)]
		[Editor(typeof(ImageEditor), typeof(UITypeEditor))]
		[TypeConverter(typeof(BinaryTypeConverter))]		
		public System.Data.Linq.Binary Photo
		{
			get
			{
				return this._Photo;
			}
			set
			{
				if ((this._Photo != value))
				{
					this.OnPhotoChanging(value);
					this.SendPropertyChanging();
					this._Photo = value;
					this.SendPropertyChanged("Photo");
					this.OnPhotoChanged();
				}
			}
		}

		[Column(Storage = "_EntityTypeID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int EntityTypeID
		{
			get
			{
				return this._EntityTypeID;
			}
			set
			{
				if ((this._EntityTypeID != value))
				{
					if (this._EntityType.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnEntityTypeIDChanging(value);
					this.SendPropertyChanging();
					this._EntityTypeID = value;
					this.SendPropertyChanged("EntityTypeID");
					this.OnEntityTypeIDChanged();
				}
			}
		}

		[Association(Name = "Entity_EntityAttribute", Storage = "_EntityAttributes", OtherKey = "EntityID", DeleteRule = "CASCADE")]
		[Browsable(false)]
		public EntitySet<EntityAttribute> EntityAttributes
		{
			get
			{
				return this._EntityAttributes;
			}
			set
			{
				this._EntityAttributes.Assign(value);
			}
		}

		[Editor(typeof(EntityAttributeCollectionEditor), typeof(UITypeEditor))]
		[DisplayName("Attributes")]
		public List<EntityAttribute> EntityAttributesList
		{
			get { return EntityAttributes.ToList(); }
		}

		[Association(Name = "Entity_GameEntity", Storage = "_GameEntities", OtherKey = "EntityID")]
		[Browsable(false)]
		public EntitySet<GameEntity> GameEntities
		{
			get
			{
				return this._GameEntities;
			}
			set
			{
				this._GameEntities.Assign(value);
			}
		}

		[Association(Name = "Entity_GPSPoint", Storage = "_GPSPoints", OtherKey = "UserID")]
		[Browsable(false)]
		public EntitySet<GPSPoint> GPSPoints
		{
			get
			{
				return this._GPSPoints;
			}
			set
			{
				this._GPSPoints.Assign(value);
			}
		}

		[Association(Name = "EntityType_Entity", Storage = "_EntityType", ThisKey = "EntityTypeID", IsForeignKey = true)]
		[TypeConverter(typeof(EntityTypeConverter))]
		[Editor(typeof(EntityTypeEditor), typeof(UITypeEditor))]
		[DisplayName("Type")]
		public EntityType EntityType
		{
			get
			{
				return this._EntityType.Entity;
			}
			set
			{
				EntityType previousValue = this._EntityType.Entity;
				if (((previousValue != value)
							|| (this._EntityType.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._EntityType.Entity = null;
						previousValue.Entities.Remove(this);
					}
					this._EntityType.Entity = value;
					if ((value != null))
					{
						value.Entities.Add(this);
						this._EntityTypeID = value.ID;
					}
					else
					{
						this._EntityTypeID = default(int);
					}
					this.SendPropertyChanged("EntityType");
				}
			}
		}

		[Association(Name = "Team_Entity", Storage = "_Team", ThisKey = "TeamID", IsForeignKey = true)]
		[Browsable(false)]
		public Team Team
		{
			get
			{
				return this._Team.Entity;
			}
			set
			{
				Team previousValue = this._Team.Entity;
				if (((previousValue != value)
							|| (this._Team.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Team.Entity = null;
						previousValue.Entities.Remove(this);
					}
					this._Team.Entity = value;
					if ((value != null))
					{
						value.Entities.Add(this);
						this._TeamID = value.ID;
					}
					else
					{
						this._TeamID = default(int);
					}
					this.SendPropertyChanged("Team");
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_EntityAttributes(EntityAttribute entity)
		{
			this.SendPropertyChanging();
			entity.Entity = this;
		}

		private void detach_EntityAttributes(EntityAttribute entity)
		{
			this.SendPropertyChanging();
			entity.Entity = null;
		}

		private void attach_GameEntities(GameEntity entity)
		{
			this.SendPropertyChanging();
			entity.Entity = this;
		}

		private void detach_GameEntities(GameEntity entity)
		{
			this.SendPropertyChanging();
			entity.Entity = null;
		}

		private void attach_GPSPoints(GPSPoint entity)
		{
			this.SendPropertyChanging();
			entity.Entity = this;
		}

		private void detach_GPSPoints(GPSPoint entity)
		{
			this.SendPropertyChanging();
			entity.Entity = null;
		}
	}

	[Table(Name = "dbo.UserToRole")]
	public partial class UserToRole : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private int _UserID;

		private int _UserRoleID;

		private EntityRef<User> _User;

		private EntityRef<UserRole> _UserRole;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnUserIDChanging(int value);
		partial void OnUserIDChanged();
		partial void OnUserRoleIDChanging(int value);
		partial void OnUserRoleIDChanged();
		#endregion

		public UserToRole()
		{
			this._User = default(EntityRef<User>);
			this._UserRole = default(EntityRef<UserRole>);
			OnCreated();
		}

		[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
		[Browsable(false)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_UserID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int UserID
		{
			get
			{
				return this._UserID;
			}
			set
			{
				if ((this._UserID != value))
				{
					if (this._User.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnUserIDChanging(value);
					this.SendPropertyChanging();
					this._UserID = value;
					this.SendPropertyChanged("UserID");
					this.OnUserIDChanged();
				}
			}
		}

		[Column(Storage = "_UserRoleID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int UserRoleID
		{
			get
			{
				return this._UserRoleID;
			}
			set
			{
				if ((this._UserRoleID != value))
				{
					if (this._UserRole.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnUserRoleIDChanging(value);
					this.SendPropertyChanging();
					this._UserRoleID = value;
					this.SendPropertyChanged("UserRoleID");
					this.OnUserRoleIDChanged();
				}
			}
		}

		[Association(Name = "User_UserToRole", Storage = "_User", ThisKey = "UserID", IsForeignKey = true)]
		[Browsable(false)]
		public User User
		{
			get
			{
				return this._User.Entity;
			}
			set
			{
				User previousValue = this._User.Entity;
				if (((previousValue != value)
							|| (this._User.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._User.Entity = null;
						previousValue.UserToRoles.Remove(this);
					}
					this._User.Entity = value;
					if ((value != null))
					{
						value.UserToRoles.Add(this);
						this._UserID = value.ID;
					}
					else
					{
						this._UserID = default(int);
					}
					this.SendPropertyChanged("User");
				}
			}
		}

		[Association(Name = "UserRole_UserToRole", Storage = "_UserRole", ThisKey = "UserRoleID", IsForeignKey = true)]
		[TypeConverter(typeof(UserRoleTypeConverter))]
		public UserRole UserRole
		{
			get
			{
				return this._UserRole.Entity;
			}
			set
			{
				UserRole previousValue = this._UserRole.Entity;
				if (((previousValue != value)
							|| (this._UserRole.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._UserRole.Entity = null;
						previousValue.UserToRoles.Remove(this);
					}
					this._UserRole.Entity = value;
					if ((value != null))
					{
						value.UserToRoles.Add(this);
						this._UserRoleID = value.ID;
					}
					else
					{
						this._UserRoleID = default(int);
					}
					this.SendPropertyChanged("UserRole");
				}
			}
		}

		/// <summary>
		/// Return Name
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			if (UserRole != null)
				return UserRole.Name;
			else
				return "New Item";
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}

	[Table(Name = "dbo.EntityAttribute")]
	public partial class EntityAttribute : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private int _EntityID;

		private int _EntityAttributeTypeID;

		private string _Value;

		private EntityRef<Entity> _Entity;

		private EntityRef<EntityAttributeType> _EntityAttributeType;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnEntityIDChanging(int value);
		partial void OnEntityIDChanged();
		partial void OnEntityAttributeTypeIDChanging(int value);
		partial void OnEntityAttributeTypeIDChanged();
		partial void OnValueChanging(string value);
		partial void OnValueChanged();
		#endregion

		public EntityAttribute()
		{
			this._Entity = default(EntityRef<Entity>);
			this._EntityAttributeType = default(EntityRef<EntityAttributeType>);
			OnCreated();
		}

		[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
		[Browsable(false)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_EntityID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int EntityID
		{
			get
			{
				return this._EntityID;
			}
			set
			{
				if ((this._EntityID != value))
				{
					if (this._Entity.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnEntityIDChanging(value);
					this.SendPropertyChanging();
					this._EntityID = value;
					this.SendPropertyChanged("EntityID");
					this.OnEntityIDChanged();
				}
			}
		}

		[Column(Storage = "_EntityAttributeTypeID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int EntityAttributeTypeID
		{
			get
			{
				return this._EntityAttributeTypeID;
			}
			set
			{
				if ((this._EntityAttributeTypeID != value))
				{
					if (this._EntityAttributeType.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnEntityAttributeTypeIDChanging(value);
					this.SendPropertyChanging();
					this._EntityAttributeTypeID = value;
					this.SendPropertyChanged("EntityAttributeTypeID");
					this.OnEntityAttributeTypeIDChanged();
				}
			}
		}

		[Column(Storage = "_Value", DbType = "NVarChar(250) NOT NULL", CanBeNull = false)]
		public string Value
		{
			get
			{
				return this._Value;
			}
			set
			{
				if ((this._Value != value))
				{
					this.OnValueChanging(value);
					this.SendPropertyChanging();
					this._Value = value;
					this.SendPropertyChanged("Value");
					this.OnValueChanged();
				}
			}
		}

		/// <summary>
		/// Use in Property Grid to show 
		/// </summary>
		public override string ToString()
		{
			if (EntityAttributeType != null)
				return EntityAttributeType.Name;
			else
				return "New Item";
		}

		[Association(Name = "Entity_EntityAttribute", Storage = "_Entity", ThisKey = "EntityID", IsForeignKey = true)]
		[Browsable(false)]
		public Entity Entity
		{
			get
			{
				return this._Entity.Entity;
			}
			set
			{
				Entity previousValue = this._Entity.Entity;
				if (((previousValue != value)
							|| (this._Entity.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Entity.Entity = null;
						previousValue.EntityAttributes.Remove(this);
					}
					this._Entity.Entity = value;
					if ((value != null))
					{
						value.EntityAttributes.Add(this);
						this._EntityID = value.ID;
					}
					else
					{
						this._EntityID = default(int);
					}
					this.SendPropertyChanged("Entity");
				}
			}
		}

		[Association(Name = "EntityAttributeType_EntityAttribute", Storage = "_EntityAttributeType", ThisKey = "EntityAttributeTypeID", IsForeignKey = true)]
		[TypeConverter(typeof(EntityAttributeTypeConverter))]
		public EntityAttributeType EntityAttributeType
		{
			get
			{
				return this._EntityAttributeType.Entity;
			}
			set
			{
				EntityAttributeType previousValue = this._EntityAttributeType.Entity;
				if (((previousValue != value)
							|| (this._EntityAttributeType.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._EntityAttributeType.Entity = null;
						previousValue.EntityAttributes.Remove(this);
					}
					this._EntityAttributeType.Entity = value;
					if ((value != null))
					{
						value.EntityAttributes.Add(this);
						this._EntityAttributeTypeID = value.ID;
					}
					else
					{
						this._EntityAttributeTypeID = default(int);
					}
					this.SendPropertyChanged("EntityAttributeType");
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}

	[Table(Name = "dbo.EntityAttributeType")]
	public partial class EntityAttributeType : INotifyPropertyChanging, INotifyPropertyChanged
	{
		public const int Person_ICQ = 1;
		public const int Person_Skype = 2;
		public const int Person_MSN = 3;
		public const int Person_Mobile = 4;
		public const int Person_Phone = 5;
		public const int Car_RegistratioNnumber = 6;
		public const int Car_Driver = 7;
		public const int Headquater_Address = 8;
		public const int Headquater_Phone = 9;
		public const int Other_Name = 10;

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private int _EntityTypeID;

		private string _Name;

		private EntitySet<EntityAttribute> _EntityAttributes;

		private EntityRef<EntityType> _EntityType;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnEntityTypeIDChanging(int value);
		partial void OnEntityTypeIDChanged();
		partial void OnNameChanging(string value);
		partial void OnNameChanged();
		#endregion

		public EntityAttributeType()
		{
			this._EntityAttributes = new EntitySet<EntityAttribute>(new Action<EntityAttribute>(this.attach_EntityAttributes), new Action<EntityAttribute>(this.detach_EntityAttributes));
			this._EntityType = default(EntityRef<EntityType>);
			OnCreated();
		}

		[Column(Storage = "_ID", DbType = "Int NOT NULL", IsPrimaryKey = true)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_EntityTypeID", DbType = "Int NOT NULL")]
		public int EntityTypeID
		{
			get
			{
				return this._EntityTypeID;
			}
			set
			{
				if ((this._EntityTypeID != value))
				{
					if (this._EntityType.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnEntityTypeIDChanging(value);
					this.SendPropertyChanging();
					this._EntityTypeID = value;
					this.SendPropertyChanged("EntityTypeID");
					this.OnEntityTypeIDChanged();
				}
			}
		}

		[Column(Storage = "_Name", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}

		public override string ToString()
		{
			return Name;
		}

		[Association(Name = "EntityAttributeType_EntityAttribute", Storage = "_EntityAttributes", OtherKey = "EntityAttributeTypeID")]
		public EntitySet<EntityAttribute> EntityAttributes
		{
			get
			{
				return this._EntityAttributes;
			}
			set
			{
				this._EntityAttributes.Assign(value);
			}
		}

		[Association(Name = "EntityType_EntityAttributeType", Storage = "_EntityType", ThisKey = "EntityTypeID", IsForeignKey = true)]
		public EntityType EntityType
		{
			get
			{
				return this._EntityType.Entity;
			}
			set
			{
				EntityType previousValue = this._EntityType.Entity;
				if (((previousValue != value)
							|| (this._EntityType.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._EntityType.Entity = null;
						previousValue.EntityAttributeTypes.Remove(this);
					}
					this._EntityType.Entity = value;
					if ((value != null))
					{
						value.EntityAttributeTypes.Add(this);
						this._EntityTypeID = value.ID;
					}
					else
					{
						this._EntityTypeID = default(int);
					}
					this.SendPropertyChanged("EntityType");
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_EntityAttributes(EntityAttribute entity)
		{
			this.SendPropertyChanging();
			entity.EntityAttributeType = this;
		}

		private void detach_EntityAttributes(EntityAttribute entity)
		{
			this.SendPropertyChanging();
			entity.EntityAttributeType = null;
		}
	}

	[Table(Name = "dbo.EntityType")]
	public partial class EntityType : INotifyPropertyChanging, INotifyPropertyChanged
	{

		public const int Person = 1;
		public const int Car = 2;
		public const int Headquater = 3;
		public const int Faked = 4;

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private string _Name;

		private EntitySet<Entity> _Entities;

		private EntitySet<EntityAttributeType> _EntityAttributeTypes;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnNameChanging(string value);
		partial void OnNameChanged();
		#endregion

		public EntityType()
		{
			this._Entities = new EntitySet<Entity>(new Action<Entity>(this.attach_Entities), new Action<Entity>(this.detach_Entities));
			this._EntityAttributeTypes = new EntitySet<EntityAttributeType>(new Action<EntityAttributeType>(this.attach_EntityAttributeTypes), new Action<EntityAttributeType>(this.detach_EntityAttributeTypes));
			OnCreated();
		}

		[Column(Storage = "_ID", DbType = "Int NOT NULL", IsPrimaryKey = true)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_Name", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}

		[Association(Name = "EntityType_Entity", Storage = "_Entities", OtherKey = "EntityTypeID")]
		public EntitySet<Entity> Entities
		{
			get
			{
				return this._Entities;
			}
			set
			{
				this._Entities.Assign(value);
			}
		}

		[Association(Name = "EntityType_EntityAttributeType", Storage = "_EntityAttributeTypes", OtherKey = "EntityTypeID")]
		public EntitySet<EntityAttributeType> EntityAttributeTypes
		{
			get
			{
				return this._EntityAttributeTypes;
			}
			set
			{
				this._EntityAttributeTypes.Assign(value);
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_Entities(Entity entity)
		{
			this.SendPropertyChanging();
			entity.EntityType = this;
		}

		private void detach_Entities(Entity entity)
		{
			this.SendPropertyChanging();
			entity.EntityType = null;
		}

		private void attach_EntityAttributeTypes(EntityAttributeType entity)
		{
			this.SendPropertyChanging();
			entity.EntityType = this;
		}

		private void detach_EntityAttributeTypes(EntityAttributeType entity)
		{
			this.SendPropertyChanging();
			entity.EntityType = null;
		}
	}

	[Table(Name = "dbo.Game")]
	[DefaultProperty("Name")]
	[TypeConverter(typeof(PropertySorter))]
	public partial class Game : INotifyPropertyChanging, INotifyPropertyChanged
	{
		protected const string CAT = "Game Details";

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private int _TeamID;

		private string _Name;

		private string _Description;

		private System.DateTime _CreationDate;

		private EntitySet<GameEntity> _GameEntities;

		private EntityRef<Team> _Team;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnTeamIDChanging(int value);
		partial void OnTeamIDChanged();
		partial void OnNameChanging(string value);
		partial void OnNameChanged();
		partial void OnDescriptionChanging(string value);
		partial void OnDescriptionChanged();
		partial void OnCreationDateChanging(System.DateTime value);
		partial void OnCreationDateChanged();
		#endregion

		public Game()
		{
			this._GameEntities = new EntitySet<GameEntity>(new Action<GameEntity>(this.attach_GameEntities), new Action<GameEntity>(this.detach_GameEntities));
			this._Team = default(EntityRef<Team>);
			OnCreated();
		}

		[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
		[Browsable(false)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_TeamID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int TeamID
		{
			get
			{
				return this._TeamID;
			}
			set
			{
				if ((this._TeamID != value))
				{
					if (this._Team.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTeamIDChanging(value);
					this.SendPropertyChanging();
					this._TeamID = value;
					this.SendPropertyChanged("TeamID");
					this.OnTeamIDChanged();
				}
			}
		}

		[Column(Storage = "_Name", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		[Category(CAT), PropertyOrder(1)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}

		[Column(Storage = "_Description", DbType = "NVarChar(250)")]
		[Category(CAT), PropertyOrder(2)]
		public string Description
		{
			get
			{
				return this._Description;
			}
			set
			{
				if ((this._Description != value))
				{
					this.OnDescriptionChanging(value);
					this.SendPropertyChanging();
					this._Description = value;
					this.SendPropertyChanged("Description");
					this.OnDescriptionChanged();
				}
			}
		}

		[Column(Storage = "_CreationDate", DbType = "DateTime NOT NULL", AutoSync = AutoSync.OnInsert, IsDbGenerated = true)]
		[Browsable(false)]
		public System.DateTime CreationDate
		{
			get
			{
				return this._CreationDate;
			}
			set
			{
				if ((this._CreationDate != value))
				{
					this.OnCreationDateChanging(value);
					this.SendPropertyChanging();
					this._CreationDate = value;
					this.SendPropertyChanged("CreationDate");
					this.OnCreationDateChanged();
				}
			}
		}

		[Association(Name = "Game_GameEntity", Storage = "_GameEntities", OtherKey = "GameID")]
		[Browsable(false)]
		public EntitySet<GameEntity> GameEntities
		{
			get
			{
				return this._GameEntities;
			}
			set
			{
				this._GameEntities.Assign(value);
			}
		}

		[Association(Name = "Team_Game", Storage = "_Team", ThisKey = "TeamID", IsForeignKey = true)]
		[Browsable(false)]
		public Team Team
		{
			get
			{
				return this._Team.Entity;
			}
			set
			{
				Team previousValue = this._Team.Entity;
				if (((previousValue != value)
							|| (this._Team.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Team.Entity = null;
						previousValue.Games.Remove(this);
					}
					this._Team.Entity = value;
					if ((value != null))
					{
						value.Games.Add(this);
						this._TeamID = value.ID;
					}
					else
					{
						this._TeamID = default(int);
					}
					this.SendPropertyChanged("Team");
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_GameEntities(GameEntity entity)
		{
			this.SendPropertyChanging();
			entity.Game = this;
		}

		private void detach_GameEntities(GameEntity entity)
		{
			this.SendPropertyChanging();
			entity.Game = null;
		}
	}

	[Table(Name = "dbo.GameEntity")]
	public partial class GameEntity : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private int _GameID;

		private int _EntityID;

		private System.Nullable<int> _ParentGameEntityID;

		private int _GameRoleID;

		private bool _Visible;

		private EntitySet<GameEntity> _GameEntities;

		private EntityRef<Entity> _Entity;

		private EntityRef<Game> _Game;

		private EntityRef<GameEntity> _GameEntity1;

		private EntityRef<GameRole> _GameRole;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnGameIDChanging(int value);
		partial void OnGameIDChanged();
		partial void OnEntityIDChanging(int value);
		partial void OnEntityIDChanged();
		partial void OnParentGameEntityIDChanging(System.Nullable<int> value);
		partial void OnParentGameEntityIDChanged();
		partial void OnGameRoleIDChanging(int value);
		partial void OnGameRoleIDChanged();
		partial void OnVisibleChanging(bool value);
		partial void OnVisibleChanged();
		#endregion

		public GameEntity()
		{
			this._GameEntities = new EntitySet<GameEntity>(new Action<GameEntity>(this.attach_GameEntities), new Action<GameEntity>(this.detach_GameEntities));
			this._Entity = default(EntityRef<Entity>);
			this._Game = default(EntityRef<Game>);
			this._GameEntity1 = default(EntityRef<GameEntity>);
			this._GameRole = default(EntityRef<GameRole>);
			OnCreated();
		}

		[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
		[Browsable(false)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Browsable(false)]
		public string Name
		{
			get
			{
				return Entity.Name;
			}
		}

		[Column(Storage = "_GameID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int GameID
		{
			get
			{
				return this._GameID;
			}
			set
			{
				if ((this._GameID != value))
				{
					if (this._Game.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnGameIDChanging(value);
					this.SendPropertyChanging();
					this._GameID = value;
					this.SendPropertyChanged("GameID");
					this.OnGameIDChanged();
				}
			}
		}

		[Column(Storage = "_EntityID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int EntityID
		{
			get
			{
				return this._EntityID;
			}
			set
			{
				if ((this._EntityID != value))
				{
					if (this._Entity.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnEntityIDChanging(value);
					this.SendPropertyChanging();
					this._EntityID = value;
					this.SendPropertyChanged("EntityID");
					this.OnEntityIDChanged();
				}
			}
		}

		[Column(Storage = "_ParentGameEntityID", DbType = "Int")]
		[Browsable(false)]
		public System.Nullable<int> ParentGameEntityID
		{
			get
			{
				return this._ParentGameEntityID;
			}
			set
			{
				if ((this._ParentGameEntityID != value))
				{
					if (this._GameEntity1.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnParentGameEntityIDChanging(value);
					this.SendPropertyChanging();
					this._ParentGameEntityID = value;
					this.SendPropertyChanged("ParentGameEntityID");
					this.OnParentGameEntityIDChanged();
				}
			}
		}

		[Column(Storage = "_GameRoleID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int GameRoleID
		{
			get
			{
				return this._GameRoleID;
			}
			set
			{
				if ((this._GameRoleID != value))
				{
					if (this._GameRole.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnGameRoleIDChanging(value);
					this.SendPropertyChanging();
					this._GameRoleID = value;
					this.SendPropertyChanged("GameRoleID");
					this.OnGameRoleIDChanged();
				}
			}
		}

		[Column(Storage = "_Visible", DbType = "Bit NOT NULL")]
		public bool Visible
		{
			get
			{
				return this._Visible;
			}
			set
			{
				if ((this._Visible != value))
				{
					this.OnVisibleChanging(value);
					this.SendPropertyChanging();
					this._Visible = value;
					this.SendPropertyChanged("Visible");
					this.OnVisibleChanged();
				}
			}
		}

		[Association(Name = "GameEntity_GameEntity", Storage = "_GameEntities", OtherKey = "ParentGameEntityID")]
		[Browsable(false)]
		public EntitySet<GameEntity> GameEntities
		{
			get
			{
				return this._GameEntities;
			}
			set
			{
				this._GameEntities.Assign(value);
			}
		}

		[Association(Name = "Entity_GameEntity", Storage = "_Entity", ThisKey = "EntityID", IsForeignKey = true)]
		[Browsable(false)]
		public Entity Entity
		{
			get
			{
				return this._Entity.Entity;
			}
			set
			{
				Entity previousValue = this._Entity.Entity;
				if (((previousValue != value)
							|| (this._Entity.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Entity.Entity = null;
						previousValue.GameEntities.Remove(this);
					}
					this._Entity.Entity = value;
					if ((value != null))
					{
						value.GameEntities.Add(this);
						this._EntityID = value.ID;
					}
					else
					{
						this._EntityID = default(int);
					}
					this.SendPropertyChanged("Entity");
				}
			}
		}

		[Association(Name = "Game_GameEntity", Storage = "_Game", ThisKey = "GameID", IsForeignKey = true)]
		[Browsable(false)]
		public Game Game
		{
			get
			{
				return this._Game.Entity;
			}
			set
			{
				Game previousValue = this._Game.Entity;
				if (((previousValue != value)
							|| (this._Game.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Game.Entity = null;
						previousValue.GameEntities.Remove(this);
					}
					this._Game.Entity = value;
					if ((value != null))
					{
						value.GameEntities.Add(this);
						this._GameID = value.ID;
					}
					else
					{
						this._GameID = default(int);
					}
					this.SendPropertyChanged("Game");
				}
			}
		}

		[Association(Name = "GameEntity_GameEntity", Storage = "_GameEntity1", ThisKey = "ParentGameEntityID", IsForeignKey = true)]
		[Browsable(false)]
		public GameEntity GameEntity1
		{
			get
			{
				return this._GameEntity1.Entity;
			}
			set
			{
				GameEntity previousValue = this._GameEntity1.Entity;
				if (((previousValue != value)
							|| (this._GameEntity1.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._GameEntity1.Entity = null;
						previousValue.GameEntities.Remove(this);
					}
					this._GameEntity1.Entity = value;
					if ((value != null))
					{
						value.GameEntities.Add(this);
						this._ParentGameEntityID = value.ID;
					}
					else
					{
						this._ParentGameEntityID = default(Nullable<int>);
					}
					this.SendPropertyChanged("GameEntity1");
				}
			}
		}

		[Association(Name = "GameRole_GameEntity", Storage = "_GameRole", ThisKey = "GameRoleID", IsForeignKey = true)]
		[TypeConverter(typeof(GameRoleConverter))]
		[DisplayName("Game Role")]
		public GameRole GameRole
		{
			get
			{
				return this._GameRole.Entity;
			}
			set
			{
				GameRole previousValue = this._GameRole.Entity;
				if (((previousValue != value)
							|| (this._GameRole.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._GameRole.Entity = null;
						previousValue.GameEntities.Remove(this);
					}
					this._GameRole.Entity = value;
					if ((value != null))
					{
						value.GameEntities.Add(this);
						this._GameRoleID = value.ID;
					}
					else
					{
						this._GameRoleID = default(int);
					}
					this.SendPropertyChanged("GameRole");
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_GameEntities(GameEntity entity)
		{
			this.SendPropertyChanging();
			entity.GameEntity1 = this;
		}

		private void detach_GameEntities(GameEntity entity)
		{
			this.SendPropertyChanging();
			entity.GameEntity1 = null;
		}
	}

	[Table(Name = "dbo.GameRole")]
	public partial class GameRole : INotifyPropertyChanging, INotifyPropertyChanged
	{
		public const int Admin = 1;
		public const int User = 2;

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private string _Name;

		private EntitySet<GameEntity> _GameEntities;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnNameChanging(string value);
		partial void OnNameChanged();
		#endregion

		public GameRole()
		{
			this._GameEntities = new EntitySet<GameEntity>(new Action<GameEntity>(this.attach_GameEntities), new Action<GameEntity>(this.detach_GameEntities));
			OnCreated();
		}

		[Column(Storage = "_ID", DbType = "Int NOT NULL", IsPrimaryKey = true)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_Name", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}

		[Association(Name = "GameRole_GameEntity", Storage = "_GameEntities", OtherKey = "GameRoleID")]
		public EntitySet<GameEntity> GameEntities
		{
			get
			{
				return this._GameEntities;
			}
			set
			{
				this._GameEntities.Assign(value);
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_GameEntities(GameEntity entity)
		{
			this.SendPropertyChanging();
			entity.GameRole = this;
		}

		private void detach_GameEntities(GameEntity entity)
		{
			this.SendPropertyChanging();
			entity.GameRole = null;
		}
	}

	[Table(Name = "dbo.GPSPoint")]
	public partial class GPSPoint : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private string _EntityName;

		private string _GameName;

		private string _Login;

		private string _Password;

		private double _Latitude;

		private double _Longitude;

		private System.DateTime _Time;

		private System.Nullable<double> _Speed;

		private System.Nullable<double> _Altitude;

		private System.Nullable<int> _GameEntityID;

		private System.Nullable<int> _UserID;

		private EntityRef<Entity> _Entity;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnEntityNameChanging(string value);
		partial void OnEntityNameChanged();
		partial void OnGameNameChanging(string value);
		partial void OnGameNameChanged();
		partial void OnLoginChanging(string value);
		partial void OnLoginChanged();
		partial void OnPasswordChanging(string value);
		partial void OnPasswordChanged();
		partial void OnLatitudeChanging(double value);
		partial void OnLatitudeChanged();
		partial void OnLongitudeChanging(double value);
		partial void OnLongitudeChanged();
		partial void OnTimeChanging(System.DateTime value);
		partial void OnTimeChanged();
		partial void OnSpeedChanging(System.Nullable<double> value);
		partial void OnSpeedChanged();
		partial void OnAltitudeChanging(System.Nullable<double> value);
		partial void OnAltitudeChanged();
		partial void OnGameEntityIDChanging(System.Nullable<int> value);
		partial void OnGameEntityIDChanged();
		partial void OnUserIDChanging(System.Nullable<int> value);
		partial void OnUserIDChanged();
		#endregion

		public GPSPoint()
		{
			this._Entity = default(EntityRef<Entity>);
			OnCreated();
		}

		[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_EntityName", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string EntityName
		{
			get
			{
				return this._EntityName;
			}
			set
			{
				if ((this._EntityName != value))
				{
					this.OnEntityNameChanging(value);
					this.SendPropertyChanging();
					this._EntityName = value;
					this.SendPropertyChanged("EntityName");
					this.OnEntityNameChanged();
				}
			}
		}

		[Column(Storage = "_GameName", DbType = "NVarChar(50)")]
		public string GameName
		{
			get
			{
				return this._GameName;
			}
			set
			{
				if ((this._GameName != value))
				{
					this.OnGameNameChanging(value);
					this.SendPropertyChanging();
					this._GameName = value;
					this.SendPropertyChanged("GameName");
					this.OnGameNameChanged();
				}
			}
		}

		[Column(Storage = "_Login", DbType = "NVarChar(50)")]
		public string Login
		{
			get
			{
				return this._Login;
			}
			set
			{
				if ((this._Login != value))
				{
					this.OnLoginChanging(value);
					this.SendPropertyChanging();
					this._Login = value;
					this.SendPropertyChanged("Login");
					this.OnLoginChanged();
				}
			}
		}

		[Column(Storage = "_Password", DbType = "NVarChar(50)")]
		public string Password
		{
			get
			{
				return this._Password;
			}
			set
			{
				if ((this._Password != value))
				{
					this.OnPasswordChanging(value);
					this.SendPropertyChanging();
					this._Password = value;
					this.SendPropertyChanged("Password");
					this.OnPasswordChanged();
				}
			}
		}

		[Column(Storage = "_Latitude", DbType = "Float NOT NULL")]
		public double Latitude
		{
			get
			{
				return this._Latitude;
			}
			set
			{
				if ((this._Latitude != value))
				{
					this.OnLatitudeChanging(value);
					this.SendPropertyChanging();
					this._Latitude = value;
					this.SendPropertyChanged("Latitude");
					this.OnLatitudeChanged();
				}
			}
		}

		[Column(Storage = "_Longitude", DbType = "Float NOT NULL")]
		public double Longitude
		{
			get
			{
				return this._Longitude;
			}
			set
			{
				if ((this._Longitude != value))
				{
					this.OnLongitudeChanging(value);
					this.SendPropertyChanging();
					this._Longitude = value;
					this.SendPropertyChanged("Longitude");
					this.OnLongitudeChanged();
				}
			}
		}

		[Column(Storage = "_Time", DbType = "DateTime NOT NULL")]
		public System.DateTime Time
		{
			get
			{
				return this._Time;
			}
			set
			{
				if ((this._Time != value))
				{
					this.OnTimeChanging(value);
					this.SendPropertyChanging();
					this._Time = value;
					this.SendPropertyChanged("Time");
					this.OnTimeChanged();
				}
			}
		}

		[Column(Storage = "_Speed", DbType = "Float")]
		public System.Nullable<double> Speed
		{
			get
			{
				return this._Speed;
			}
			set
			{
				if ((this._Speed != value))
				{
					this.OnSpeedChanging(value);
					this.SendPropertyChanging();
					this._Speed = value;
					this.SendPropertyChanged("Speed");
					this.OnSpeedChanged();
				}
			}
		}

		[Column(Storage = "_Altitude", DbType = "Float")]
		public System.Nullable<double> Altitude
		{
			get
			{
				return this._Altitude;
			}
			set
			{
				if ((this._Altitude != value))
				{
					this.OnAltitudeChanging(value);
					this.SendPropertyChanging();
					this._Altitude = value;
					this.SendPropertyChanged("Altitude");
					this.OnAltitudeChanged();
				}
			}
		}

		[Column(Storage = "_GameEntityID", DbType = "Int")]
		public System.Nullable<int> GameEntityID
		{
			get
			{
				return this._GameEntityID;
			}
			set
			{
				if ((this._GameEntityID != value))
				{
					this.OnGameEntityIDChanging(value);
					this.SendPropertyChanging();
					this._GameEntityID = value;
					this.SendPropertyChanged("GameEntityID");
					this.OnGameEntityIDChanged();
				}
			}
		}

		[Column(Storage = "_UserID", DbType = "Int")]
		public System.Nullable<int> UserID
		{
			get
			{
				return this._UserID;
			}
			set
			{
				if ((this._UserID != value))
				{
					if (this._Entity.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnUserIDChanging(value);
					this.SendPropertyChanging();
					this._UserID = value;
					this.SendPropertyChanged("UserID");
					this.OnUserIDChanged();
				}
			}
		}

		[Association(Name = "Entity_GPSPoint", Storage = "_Entity", ThisKey = "UserID", IsForeignKey = true)]
		public Entity Entity
		{
			get
			{
				return this._Entity.Entity;
			}
			set
			{
				Entity previousValue = this._Entity.Entity;
				if (((previousValue != value)
							|| (this._Entity.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Entity.Entity = null;
						previousValue.GPSPoints.Remove(this);
					}
					this._Entity.Entity = value;
					if ((value != null))
					{
						value.GPSPoints.Add(this);
						this._UserID = value.ID;
					}
					else
					{
						this._UserID = default(Nullable<int>);
					}
					this.SendPropertyChanged("Entity");
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}

	[Table(Name = "dbo.MarkerHash")]
	public partial class MarkerHash : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private System.DateTime _Hash;

		private string _MarkerName;

		private string _GameName;

		private string _Login;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnHashChanging(System.DateTime value);
		partial void OnHashChanged();
		partial void OnMarkerNameChanging(string value);
		partial void OnMarkerNameChanged();
		partial void OnGameNameChanging(string value);
		partial void OnGameNameChanged();
		partial void OnLoginChanging(string value);
		partial void OnLoginChanged();
		#endregion

		public MarkerHash()
		{
			OnCreated();
		}

		[Column(Storage = "_Hash", DbType = "DateTime NOT NULL", IsPrimaryKey = true)]
		public System.DateTime Hash
		{
			get
			{
				return this._Hash;
			}
			set
			{
				if ((this._Hash != value))
				{
					this.OnHashChanging(value);
					this.SendPropertyChanging();
					this._Hash = value;
					this.SendPropertyChanged("Hash");
					this.OnHashChanged();
				}
			}
		}

		[Column(Storage = "_MarkerName", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string MarkerName
		{
			get
			{
				return this._MarkerName;
			}
			set
			{
				if ((this._MarkerName != value))
				{
					this.OnMarkerNameChanging(value);
					this.SendPropertyChanging();
					this._MarkerName = value;
					this.SendPropertyChanged("MarkerName");
					this.OnMarkerNameChanged();
				}
			}
		}

		[Column(Storage = "_GameName", DbType = "NVarChar(50)")]
		public string GameName
		{
			get
			{
				return this._GameName;
			}
			set
			{
				if ((this._GameName != value))
				{
					this.OnGameNameChanging(value);
					this.SendPropertyChanging();
					this._GameName = value;
					this.SendPropertyChanged("GameName");
					this.OnGameNameChanged();
				}
			}
		}

		[Column(Storage = "_Login", DbType = "NVarChar(50)")]
		public string Login
		{
			get
			{
				return this._Login;
			}
			set
			{
				if ((this._Login != value))
				{
					this.OnLoginChanging(value);
					this.SendPropertyChanging();
					this._Login = value;
					this.SendPropertyChanged("Login");
					this.OnLoginChanged();
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}

	[Table(Name = "dbo.Team")]
	public partial class Team : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private string _Name;

		private string _Description;

		private EntitySet<Entity> _Entities;

		private EntitySet<Game> _Games;

		private EntitySet<User> _Users;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnNameChanging(string value);
		partial void OnNameChanged();
		partial void OnDescriptionChanging(string value);
		partial void OnDescriptionChanged();
		#endregion

		public Team()
		{
			this._Entities = new EntitySet<Entity>(new Action<Entity>(this.attach_Entities), new Action<Entity>(this.detach_Entities));
			this._Games = new EntitySet<Game>(new Action<Game>(this.attach_Games), new Action<Game>(this.detach_Games));
			this._Users = new EntitySet<User>(new Action<User>(this.attach_Users), new Action<User>(this.detach_Users));
			OnCreated();
		}

		[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
		[Browsable(false)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_Name", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}

		[Column(Storage = "_Description", DbType = "NVarChar(250)")]
		public string Description
		{
			get
			{
				return this._Description;
			}
			set
			{
				if ((this._Description != value))
				{
					this.OnDescriptionChanging(value);
					this.SendPropertyChanging();
					this._Description = value;
					this.SendPropertyChanged("Description");
					this.OnDescriptionChanged();
				}
			}
		}

		[Association(Name = "Team_Entity", Storage = "_Entities", OtherKey = "TeamID")]
		[Browsable(false)]
		public EntitySet<Entity> Entities
		{
			get
			{
				return this._Entities;
			}
			set
			{
				this._Entities.Assign(value);
			}
		}

		[Association(Name = "Team_Game", Storage = "_Games", OtherKey = "TeamID")]
		[Browsable(false)]
		public EntitySet<Game> Games
		{
			get
			{
				return this._Games;
			}
			set
			{
				this._Games.Assign(value);
			}
		}

		[Association(Name = "Team_User", Storage = "_Users", OtherKey = "TeamID")]
		[Browsable(false)]
		public EntitySet<User> Users
		{
			get
			{
				return this._Users;
			}
			set
			{
				this._Users.Assign(value);
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_Entities(Entity entity)
		{
			this.SendPropertyChanging();
			entity.Team = this;
		}

		private void detach_Entities(Entity entity)
		{
			this.SendPropertyChanging();
			entity.Team = null;
		}

		private void attach_Games(Game entity)
		{
			this.SendPropertyChanging();
			entity.Team = this;
		}

		private void detach_Games(Game entity)
		{
			this.SendPropertyChanging();
			entity.Team = null;
		}

		private void attach_Users(User entity)
		{
			this.SendPropertyChanging();
			entity.Team = this;
		}

		private void detach_Users(User entity)
		{
			this.SendPropertyChanging();
			entity.Team = null;
		}
	}

	[Table(Name = "dbo.[User]")]
	public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private string _Login;

		private string _Password;

		private int _TeamID;

		private EntitySet<UserToRole> _UserToRoles;

		private EntityRef<Team> _Team;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnLoginChanging(string value);
		partial void OnLoginChanged();
		partial void OnPasswordChanging(string value);
		partial void OnPasswordChanged();
		partial void OnTeamIDChanging(int value);
		partial void OnTeamIDChanged();
		#endregion

		public User()
		{
			this._UserToRoles = new EntitySet<UserToRole>(new Action<UserToRole>(this.attach_UserToRoles), new Action<UserToRole>(this.detach_UserToRoles));
			this._Team = default(EntityRef<Team>);
			OnCreated();
		}

		/// <summary>
		/// Check Admin rights
		/// </summary>
		/// <returns></returns>
		[Browsable(false)]
		public bool IsAdmin
		{
			get
			{
				return (from ur in UserToRoles where ur.UserRoleID == UserRole.Admin select ur).Count() > 0;
			}
		}

		/// <summary>
		/// Check team admin rights
		/// </summary>
		/// <returns></returns>
		[Browsable(false)]
		public bool IsTeamAdmin
		{
			get
			{
				return (from ur in UserToRoles where ur.UserRoleID == UserRole.TeamAdmin select ur).Count() > 0;
			}
		}

		/// <summary>
		/// Check Read only rights
		/// </summary>
		/// <returns></returns>
		[Browsable(false)]
		public bool IsReadOnly
		{
			get
			{
				return (from ur in UserToRoles where ur.UserRoleID == UserRole.ReadOnly select ur).Count() > 0;
			}
		}

		/// <summary>
		/// User description
		/// </summary>
		[Browsable(false)]
		public string Description
		{
			get
			{
				return ToString();
			}
		}

		/// <summary>
		/// Return Name
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			string text = Login;
			StringCollection userRightsCollection = new StringCollection();
			if (IsAdmin)
				userRightsCollection.Add("Admin");
			if (IsTeamAdmin)
				userRightsCollection.Add("Team Admin");
			if (IsReadOnly)
				userRightsCollection.Add("Read only");
			if (userRightsCollection.Count == 0)
				userRightsCollection.Add("No Rights");
			for (int i = 0; i < userRightsCollection.Count; i++)
			{
				text += (i == 0 ? " (" : string.Empty)
					+ userRightsCollection[i]
					+ (i == userRightsCollection.Count - 1 ? string.Empty : ", ")
					+ (i == userRightsCollection.Count - 1 ? ")" : string.Empty);
			}
			return text;
		}

		[Column(Storage = "_ID", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
		[Browsable(false)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_Login", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string Login
		{
			get
			{
				return this._Login;
			}
			set
			{
				if ((this._Login != value))
				{
					this.OnLoginChanging(value);
					this.SendPropertyChanging();
					this._Login = value;
					this.SendPropertyChanged("Login");
					this.OnLoginChanged();
				}
			}
		}

		[Browsable(false)]
		public string Name
		{
			get
			{
				return Login;
			}
		}

		[Column(Storage = "_Password", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		[PasswordPropertyText(true)]
		public string Password
		{
			get
			{
				return this._Password;
			}
			set
			{
				if ((this._Password != value))
				{
					this.OnPasswordChanging(value);
					this.SendPropertyChanging();
					this._Password = value;
					this.SendPropertyChanged("Password");
					this.OnPasswordChanged();
				}
			}
		}

		[Column(Storage = "_TeamID", DbType = "Int NOT NULL")]
		[Browsable(false)]
		public int TeamID
		{
			get
			{
				return this._TeamID;
			}
			set
			{
				if ((this._TeamID != value))
				{
					if (this._Team.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTeamIDChanging(value);
					this.SendPropertyChanging();
					this._TeamID = value;
					this.SendPropertyChanged("TeamID");
					this.OnTeamIDChanged();
				}
			}
		}

		[Association(Name = "User_UserToRole", Storage = "_UserToRoles", OtherKey = "UserID")]
		[Browsable(false)]
		public EntitySet<UserToRole> UserToRoles
		{
			get
			{
				return this._UserToRoles;
			}
			set
			{
				this._UserToRoles.Assign(value);
			}
		}

		[Editor(typeof(UserToRolesCollectionEditor), typeof(UITypeEditor))]
		[DisplayName("Roles")]
		public List<UserToRole> UserToRolesList
		{
			get { return UserToRoles.ToList(); }
		}


		[Association(Name = "Team_User", Storage = "_Team", ThisKey = "TeamID", IsForeignKey = true)]
		[Browsable(false)]
		public Team Team
		{
			get
			{
				return this._Team.Entity;
			}
			set
			{
				Team previousValue = this._Team.Entity;
				if (((previousValue != value)
							|| (this._Team.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Team.Entity = null;
						previousValue.Users.Remove(this);
					}
					this._Team.Entity = value;
					if ((value != null))
					{
						value.Users.Add(this);
						this._TeamID = value.ID;
					}
					else
					{
						this._TeamID = default(int);
					}
					this.SendPropertyChanged("Team");
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_UserToRoles(UserToRole entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}

		private void detach_UserToRoles(UserToRole entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
	}

	[Table(Name = "dbo.UserRole")]
	public partial class UserRole : INotifyPropertyChanging, INotifyPropertyChanged
	{
		public const int Admin = 1;
		public const int TeamAdmin = 2;
		public const int ReadOnly = 3;

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _ID;

		private string _Name;

		private EntitySet<UserToRole> _UserToRoles;

		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnIDChanging(int value);
		partial void OnIDChanged();
		partial void OnNameChanging(string value);
		partial void OnNameChanged();
		#endregion

		public UserRole()
		{
			this._UserToRoles = new EntitySet<UserToRole>(new Action<UserToRole>(this.attach_UserToRoles), new Action<UserToRole>(this.detach_UserToRoles));
			OnCreated();
		}

		[Column(Storage = "_ID", DbType = "Int NOT NULL", IsPrimaryKey = true)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}

		[Column(Storage = "_Name", DbType = "NVarChar(50) NOT NULL", CanBeNull = false)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}

		[Association(Name = "UserRole_UserToRole", Storage = "_UserToRoles", OtherKey = "UserRoleID")]
		public EntitySet<UserToRole> UserToRoles
		{
			get
			{
				return this._UserToRoles;
			}
			set
			{
				this._UserToRoles.Assign(value);
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		private void attach_UserToRoles(UserToRole entity)
		{
			this.SendPropertyChanging();
			entity.UserRole = this;
		}

		private void detach_UserToRoles(UserToRole entity)
		{
			this.SendPropertyChanging();
			entity.UserRole = null;
		}
	}
}
#pragma warning restore 1591
